var mesdong = null;
var mestime = 180;
function getcode(phone, btn, _this){
	$.ajax({
		data: {phone: phone},
		type: "post",
		url: '/index/login/getcode',
		dataType: "json",
		success: function (d) {
			if (d.code == 200){
				_this.attr('able', "disable");
				_this.css('cursor', 'not-allowed');
				_this.val(mestime + "s");
				mesdong = setInterval(function () {
					mestime -= 1;
					if (mestime < 0) {
						$("#"+btn+"-mescode-btn").attr('able', "able");
						$("#"+btn+"-mescode-btn").css('cursor', 'pointer');
						$("#"+btn+"-mescode-btn").val('获取验证码');
						mestime = 180;
						clearInterval(mesdong);
					} else {
						$("#"+btn+"-mescode-btn").val(mestime + "s");
					};
				}, 1000);
			} else {
				$("#"+btn+"-phone-text").html(d.msg).show();
			}
		},
		error: function (d) {}
	});
}

var flage = false;
function checkcode(phone, code, btn){
	$.ajax({
		data: {phone: phone, code: code},
		type: "post",
		url: '/index/login/checkcode',
		dataType: "json",
		async: false,
		success: function (d) {
			if (d.code == 200){
				flage = true;
			} else {
				$("#"+btn+"-mescode-text").html(d.msg).show();
				flage = false;
			}
		},
		error: function (d) {}
	});
	return flage;
}
function checkphone(phone, btn){
	$.ajax({
		data: {phone: phone, btn: btn},
		type: "post",
		url: '/index/login/checkphone',
		dataType: "json",
		async: false,
		success: function (d) {
			if (d.code == 200){
				flage = true;
			} else {
				$("#"+btn+"-phone-text").html(d.msg).show();
				flage = false;
			}
		},
		error: function (d) {}
	});
	return flage;
}